import React from 'react'
import axios from 'axios'
class NewAxios extends React.Component {
    getStudentData = () => {
      // axios.get('http://localhost:3000/students').then(response => {
      //     console.log('请求成功', response.data)
      // }).catch(err => {
      //     console.log('请求失败!',err)
      // })
      //   axios.get('http://localhost:5000/students').then(response => {
      //       console.log('请求成功', response.data)
      //   },err => {
      //       console.log('请求失败！', err)
      //   })
        axios.get('http://localhost:3000/api1/students').then(response => {
            console.log('请求成功', response.data)
        }).catch(err => {
            console.log('请求失败!',err)
        })
    }
    getCarData = () => {
        axios.get('http://localhost:3000/api2/cars').then(response => {
            console.log('请求成功', response.data)
        }).catch(err => {
            console.log('请求失败!',err)
        })
    }
    render() {
        return(
            <div>
                <button onClick={this.getStudentData}>请求数据1</button>
                <button onClick={this.getCarData}>请求数据2</button>
            </div>
        )
    }
}
export default NewAxios